﻿using System;
using BehaviorModel.Block;
using BehaviorModel.Block.Generator;
using BehaviorModel.Block.ServiceChannel;
using BehaviorModel.Block.Splitter;
using BehaviorModel.Block.Summator;
using Model.Block;

namespace BehaviorModel
{
    /// <summary>
    /// Describes implementation of factory of all block types in QSM.
    /// </summary>
    public class BlockFactory : IBlockFactory
    {
        private static readonly IBlockFactory _instance = new BlockFactory();

        private BlockFactory()
        {
        }

        public static IBlockFactory GetInstance()
        {
            return _instance;
        }

        public IBlock Create(BlockType type)
        {
            switch (type)
            {
                case BlockType.Generator: return new Generator();
                case BlockType.ServiceChannel: return new ServiceChannel();
                case BlockType.Summator: return new Summator();
                case BlockType.Splitter: return new Splitter();
                default: throw new ArgumentException("Неизвестный тип блока!");
            }
        }
    }
}